package controlFlowGraph;

import java.util.HashSet;
import java.util.Set;

import domains.Interval;
import domains.IntervalDomain;

public class Variable extends Expression {

	private String varName;
	
	public Variable(String var) {
		this.varName = var;
	}

	@Override
	public String toString() {
		return varName;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Variable) {
			Variable v = (Variable) obj;
			return v.toString().equals(this.varName);
		}
		return false;
	}

	@Override
	public int hashCode() {
		return this.varName.hashCode();
	}

	@Override
	public Set<Variable> getInvolvedVariables() {
		Set<Variable> res = new HashSet<Variable>();
		res.add(this);
		return res;
	}

	@Override
	public boolean isTrivial() {
		return true;
	}
	
	@Override
	public Interval abstractExpressionEvaluation(IntervalDomain dom){
		Interval exp;
		Interval var = dom.getIntervals().get(this);
		exp = new Interval(var.getLeft(),var.getRight());
		return exp;
	}
}
